home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / programming / amigae / xpk25edev / source / xpk.e < prev    next >
Encoding:
Text File  |  1996-01-17  |  11.1 KB  |  320 lines

  1. /*
  2. **    $Filename: xpk.h $
  3. **    $Release: 0.9 $
  4. **
  5. **
  6. **
  7. **    (C) Copyright 1991 U. Dominik Mueller, Bryan Ford, Christian Schneider
  8. **        All Rights Reserved
  9. */
  10.  
  11.  
  12. /*
  13. **  Converted from C include file to E module by
  14. **  Torgil Svenssom (snorq@lysator.liu.se) in 1995
  15. **
  16. **  see the file E.README
  17. **
  18. */
  19.  
  20.  
  21. OPT MODULE
  22. OPT PREPROCESS
  23. OPT EXPORT
  24.  
  25.  
  26. -> there are two defines left. this and one at the bottom
  27.  
  28. #define XPKNAME 'xpkmaster.library'
  29.  
  30. /*****************************************************************************
  31.  *
  32.  *
  33.  *      The packing/unpacking tags
  34.  *
  35.  */
  36.  
  37. CONST XPK_TagBase = TAG_USER + "X"*256 + "P"
  38. CONST XTAG        = XPK_TagBase
  39.  
  40. -> Caller must supply ONE of these to tell Xpk#?ackFile where to get data from
  41.  
  42. CONST XPK_InName = XTAG+$01,  -> Process an entire named file
  43.       XPK_InFH   = XTAG+$02   -> File handle - start from current position
  44.  
  45. -> If packing partial file, must also supply InLen
  46.  
  47. CONST XPK_InBuf  = XTAG+$03,  -> Single unblocked memory buffer, supply InLen
  48.       XPK_InHook = XTAG+$04   -> Call custom Hook to read data
  49.  
  50. -> If packing, must also supply InLen
  51. -> If unpacking, InLen required only for PPDecrunch
  52.  
  53. -> Caller must supply ONE of these to tell Xpk#?ackFile where to send data to
  54. CONST XPK_OutName   = XTAG+$10, -> Write (or overwrite) this data file
  55.       XPK_OutFH     = XTAG+$11, -> File handle - write from current pos on
  56.       XPK_OutBuf    = XTAG+$12,    -> Unblocked buf - must also supply OutBufLen
  57.       XPK_GetOutBuf = XTAG+$13,    -> Master alloc. OutBuf tag data pts to buf ptr
  58.       XPK_OutHook   = XTAG+$14  -> Callback Hook to get output buffers
  59.  
  60. -> Other tags for Pack/Unpack
  61. CONST XPK_InLen        = XTAG+$20,  -> Length of data in input buffer
  62.       XPK_OutBufLen    = XTAG+$21,  -> Length of output buffer
  63.       XPK_GetOutLen    = XTAG+$22,  -> tag data pts to long to receive OutLen
  64.       XPK_GetOutBufLen = XTAG+$23,  -> tag data pts to long to rec. OutBufLen
  65.       XPK_Password     = XTAG+$24,  -> Password for de/encoding
  66.       XPK_GetError     = XTAG+$25,  -> ti_Data points to buf for error message
  67.       XPK_OutMemType   = XTAG+$26,  -> Memory type for output buffer
  68.       XPK_PassThru     = XTAG+$27,  -> Bool: Pass through unrec.formats on unpck
  69.       XPK_StepDown     = XTAG+$28,  -> Bool: Step down pack method if necessary
  70.       XPK_ChunkHook    = XTAG+$29,  -> Call this Hook between chunks
  71.       XPK_PackMethod   = XTAG+$2a,  -> Do a FindMethod before packing
  72.       XPK_ChunkSize    = XTAG+$2b,  -> Chunk size to try to pack with
  73.       XPK_PackMode     = XTAG+$2c,  -> Packing mode for sublib to use
  74.       XPK_NoClobber    = XTAG+$2d,  -> Don't overwrite existing files
  75.       XPK_Ignore       = XTAG+$2e,  -> Skip this tag
  76.       XPK_TaskPri      = XTAG+$2f,  -> Change priority for (un)packing
  77.       XPK_FileName     = XTAG+$30,  -> File name for progress report
  78.       XPK_ShortError   = XTAG+$31,  -> Output short error messages
  79.       XPK_PackersQuery = XTAG+$32,  -> Query available packers
  80.       XPK_PackerQuery  = XTAG+$33,  -> Query properties of a packer
  81.       XPK_ModeQuery    = XTAG+$34,  -> Query properties of packmode
  82.       XPK_LossyOK      = XTAG+$35   -> Lossy packing permitted? def.=no
  83.  
  84.  
  85. CONST XPK_FindMethod = XPK_PackMethod, -> Compatibility
  86.       XPK_MARGIN     = 256             -> Safety margin for output buffer
  87.  
  88.  
  89.  
  90.  
  91. /*****************************************************************************
  92.  *
  93.  *
  94.  *     The hook function interface
  95.  *
  96.  */
  97.  
  98. -> Message passed to InHook and OutHook as the ParamPacket
  99. OBJECT xpkIOMsg
  100.     type      :LONG   -> (unsigned) Read/Write/Alloc/Free/Abort
  101.     ptr       :LONG   -> (APTR) The mem area to read from/write to
  102.     size      :LONG   -> The size of the read/write
  103.     ioError   :LONG   -> The IoErr() that occurred
  104.     reserved  :LONG   -> Reserved for future use
  105.     private1  :LONG   -> Hook specific, will be set to 0 by
  106.     private2  :LONG   -> master library before first use
  107.     private3  :LONG
  108.     private4  :LONG
  109. ENDOBJECT
  110.  
  111. -> The values for xpkIoMsg.type
  112. CONST XIO_READ    = 1,
  113.       XIO_WRITE   = 2,
  114.       XIO_FREE    = 3,
  115.       XIO_ABORT   = 4,
  116.       XIO_GETBUF  = 5,
  117.       XIO_SEEK    = 6,
  118.       XIO_TOTSIZE = 7
  119.  
  120.  
  121.  
  122.  
  123.  
  124. /*****************************************************************************
  125.  *
  126.  *
  127.  *      The progress report interface
  128.  *
  129.  */
  130.  
  131. -> Passed to ChunkHook as the ParamPacket
  132. OBJECT xpkProgress
  133.   type          :LONG         -> Type of report: start/cont/end/abort
  134.   packerName    :PTR TO CHAR    -> Brief name of packer being used
  135.   packerLongName:PTR TO CHAR  -> Descriptive name of packer being used
  136.   activity      :PTR TO CHAR  -> Packing/unpacking message
  137.   fileName      :PTR TO CHAR  -> Name of file being processed, if available
  138.  
  139.   ccur          :LONG   -> Amount of packed data already processed
  140.   ucur          :LONG   -> Amount of unpacked data already processed
  141.   ulen          :LONG   -> Amount of unpacked data in file
  142.   cf            :LONG   -> Compression factor so far
  143.   done          :LONG   -> Percentage done already
  144.   speed         :LONG   -> Bytes per second, from beginning of stream
  145.   reserved[8]   :ARRAY  -> For future use
  146. ENDOBJECT
  147.  
  148. CONST XPKPROG_START = 1,
  149.       XPKPROG_MID   = 2,
  150.       XPKPROG_END   = 3
  151.  
  152.  
  153.  
  154.  
  155.  
  156. /*****************************************************************************
  157.  *
  158.  *
  159.  *       The file info block
  160.  *
  161.  */
  162.  
  163. OBJECT xpkFib
  164.   type  :LONG   -> Unpacked, packed, archive?
  165.   ulen  :LONG   -> Uncompressed length
  166.   dlen  :LONG   -> Compressed length
  167.   nlen  :LONG   -> Next chunk len
  168.   ucur  :LONG   -> Uncompressed bytes so far
  169.   ccur  :LONG        -> Compressed bytes so far
  170.   id    :LONG        -> 4 letter ID of packer
  171.  
  172.   packer[6]   :ARRAY  -> (unsigned) 4 letter name of packer
  173.   subVersion  :INT    -> Required sublib version
  174.   masVersion  :INT    -> Required masterlib version
  175.   flags       :INT    -> Password?
  176.   head[16]    :ARRAY  -> (unsigned) First 16 bytes of orig. file
  177.   ratio       :LONG   -> Compression ratio
  178.  
  179.   reserved[8] :ARRAY OF LONG    -> For future use
  180. ENDOBJECT
  181.  
  182. CONST XPKTYPE_UNPACKED  = 0,  -> Not packed
  183.       XPKTYPE_PACKED    = 1,  -> Packed file
  184.       XPKTYPE_ARCHIVE   = 2   -> Archive
  185.  
  186. CONST XPKFLAGS_PASSWORD = 1,  -> Password needed
  187.       XPKFLAGS_NOSEEK   = 2,  -> Chunks are dependent
  188.       XPKFLAGS_NONSTD   = 4   -> Nonstandard file format
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. /*****************************************************************************
  196.  *
  197.  *
  198.  *       The error messages
  199.  *
  200.  */
  201.  
  202. CONST XPKERR_OK          =   0,
  203.       XPKERR_NOFUNC      =  -1, -> This function not implemented
  204.       XPKERR_NOFILES     =  -2, -> No files allowed for this function
  205.       XPKERR_IOERRIN     =  -3, -> Input error happened, look at Result2
  206.       XPKERR_IOERROUT    =  -4, -> Output error happened,look at Result2
  207.       XPKERR_CHECKSUM    =  -5, -> Check sum test failed
  208.       XPKERR_VERSION     =  -6, -> Packed file's version newer than lib
  209.       XPKERR_NOMEM       =  -7, -> Out of memory
  210.       XPKERR_LIBINUSE    =  -8, -> For not-reentrant libraries
  211.       XPKERR_WRONGFORM   =  -9, -> Was not packed with this library
  212.       XPKERR_SMALLBUF    = -10, -> Output buffer too small
  213.       XPKERR_LARGEBUF    = -11, -> Input buffer too large
  214.       XPKERR_WRONGMODE   = -12, -> This packing mode not supported
  215.       XPKERR_NEEDPASSWD  = -13, -> Password needed for decoding
  216.       XPKERR_CORRUPTPKD  = -14, -> Packed file is corrupt
  217.       XPKERR_MISSINGLIB  = -15, -> Required library is missing
  218.       XPKERR_BADPARAMS   = -16, -> Caller's TagList was screwed up
  219.       XPKERR_EXPANSION   = -17, -> Would have caused data expansion
  220.       XPKERR_NOMETHOD    = -18, -> Can't find requested method
  221.       XPKERR_ABORTED     = -19, -> Operation aborted by user
  222.       XPKERR_TRUNCATED   = -20, -> Input file is truncated
  223.       XPKERR_WRONGCPU    = -21, -> Better CPU required for this library
  224.       XPKERR_PACKED      = -22, -> Data are already XPacked
  225.       XPKERR_NOTPACKED   = -23, -> Data not packed
  226.       XPKERR_FILEEXISTS  = -24, -> File already exists
  227.       XPKERR_OLDMASTLIB  = -25, -> Master library too old
  228.       XPKERR_OLDSUBLIB   = -26, -> Sub library too old
  229.       XPKERR_NOCRYPT     = -27, -> Cannot encrypt
  230.       XPKERR_NOINFO      = -28, -> Can't get info on that packer
  231.       XPKERR_LOSSY       = -29, -> This compression method is lossy
  232.       XPKERR_NOHARDWARE  = -30, -> Compression hardware required
  233.       XPKERR_BADHARDWARE = -31, -> Compression hardware failed
  234.       XPKERR_WRONGPW     = -32  -> Password was wrong
  235.  
  236.  
  237. CONST XPKERRMSGSIZE    = 80    ->  Maximum size of an error message
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244. /*****************************************************************************
  245.  *
  246.  *
  247.  *     The XpkQuery() call
  248.  *
  249.  */
  250.  
  251. OBJECT xpkPackerInfo
  252.   name[24]        :ARRAY  -> Brief name of the packer
  253.   longName[32]    :ARRAY  -> Full name of the packer
  254.   description[80] :ARRAY  -> One line description of packer
  255.  
  256.   flags     :LONG   -> Defined below
  257.   maxChunk  :LONG   -> Max input chunk size for packing
  258.   defChunk  :LONG   -> Default packing chunk size
  259.   defMode   :INT    -> (unsigned) Default mode on 0..100 scale
  260. ENDOBJECT
  261.  
  262. -> Defines for Flags
  263. CONST XPKIF_PK_CHUNK    = $00000001, -> Library supplies chunk packing
  264.       XPKIF_PK_STREAM   = $00000002, -> Library supplies stream packing
  265.       XPKIF_PK_ARCHIVE  = $00000004, -> Library supplies archive packing
  266.       XPKIF_UP_CHUNK    = $00000008, -> Library supplies chunk unpacking
  267.       XPKIF_UP_STREAM   = $00000010, -> Library supplies stream unpacking
  268.       XPKIF_UP_ARCHIVE  = $00000020, -> Library supplies archive unpacking
  269.       XPKIF_HOOKIO      = $00000080, -> Uses full Hook I/O
  270.       XPKIF_CHECKING    = $00000400, -> Does its own data checking
  271.       XPKIF_PREREADHDR  = $00000800, -> Unpacker pre-reads the next chunkhdr
  272.       XPKIF_ENCRYPTION  = $00002000, -> Sub library supports encryption
  273.       XPKIF_NEEDPASSWD  = $00004000, -> Sub library requires encryption
  274.       XPKIF_MODES       = $00008000, -> Sub library has different modes
  275.       XPKIF_LOSSY       = $00010000  -> Sub library does lossy compression
  276.  
  277.  
  278. OBJECT xpkMode
  279.   next  :PTR TO xpkMode -> Chain to next descriptor for ModeDesc list*/
  280.  
  281.   upto        :LONG     -> (unsigned) Maximum efficiency handled by this mode
  282.   flags       :LONG     -> (unsigned) Defined below
  283.   packMemory  :LONG     -> (unsigned) Extra memory required during packing
  284.   unpackMemory:LONG     -> (unsigned) Extra memory during unpacking
  285.   packSpeed   :LONG     -> (unsigned) Approx packing speed in K per second
  286.   unpackSpeed :LONG     -> (unsigned) Approx unpacking speed in K per second
  287.   ratio       :INT      -> (unsigned) CF in 0.1% for AmigaVision executable
  288.   chunkSize   :INT      -> (unsigned) Desired chunk size in K (!!) for this mode
  289.  
  290.   description[10]:ARRAY -> 7 character mode description
  291. ENDOBJECT
  292.  
  293. -> Defines for XpkMode.Flags
  294. CONST XPKMF_A3000SPEED = $00000001, -> Timings on A3000/25
  295.       XPKMF_PK_NOCPU   = $00000002, -> Packing not heavily CPU dependent
  296.       XPKMF_UP_NOCPU   = $00000004  -> Unpacking... (i.e. hardware modes)
  297.  
  298. CONST MAXPACKERS = 100
  299. CONST XPK_PACKER_ARRAY_SIZE = MAXPACKERS * 6
  300.  
  301. OBJECT xpkPackerList
  302.   numPackers                    :LONG   -> (unsigned)
  303.   packer[XPK_PACKER_ARRAY_SIZE] :ARRAY  -> MAXPACKERS items. 6 bytes each
  304. ENDOBJECT
  305.  
  306.  
  307.  
  308.  
  309. /*****************************************************************************
  310.  *
  311.  *
  312.  *     The XpkOpen() type calls
  313.  *
  314.  */
  315.  
  316. CONST XPKLEN_ONECHUNK = $7fffffff
  317.  
  318. #define xpkFH xpkFib
  319.  
  320.